package com.tedu.lingma.agent.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.tedu.lingma.agent.assistant.Assistant;
import com.tedu.lingma.agent.domain.FormMessage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.models.annotations.OpenAPI30;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

@Tag(name="灵码挂号")
@RestController
@RequestMapping("/lingma")
public class LingMaController {

    @Autowired
    private Assistant assistant;

    // API接口中的一个操作
    //  RequestBody  请求必须是以JSON字符串请求  然后将请求的数据封装到FormMessage对象
    @Operation(summary = "聊天")
    @PostMapping(value = "/chat",produces = "text/stream;charset=utf-8")
    public Flux<String> chat(@RequestBody FormMessage formMessage) {
        return assistant.chat(formMessage.getMemoryId(), formMessage.getMessage());
    }

}
